﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:SampleData="clr-namespace:Expression.Blend.SampleData.PlaylistsDataSource" x:Name="phoneApplicationPage" 
    x:Class="ToyundaPhone.Pages.PlaylistsPage"
    SupportedOrientations="PortraitOrLandscape"
    mc:Ignorable="d" Orientation="Portrait"
    d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">

	<phone:PhoneApplicationPage.Resources>
		<SampleData:PlaylistsDataSource x:Key="PlaylistsDataSource" d:IsDataSource="True"/>
		<Style x:Key="ListBoxItemWithNoSelectionStyle" TargetType="ListBoxItem">
			<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBoxItem">
						<Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="LayoutRoot">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="SelectionStates">
									<VisualState x:Name="Unselected"/>
									<VisualState x:Name="Selected" />
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<DataTemplate x:Key="PlaylistsItemTemplate">
			<Border Padding="{StaticResource PhoneTouchTargetOverhang}" Tap="Playlist_Tap">
				<toolkit:ContextMenuService.ContextMenu>
					<toolkit:ContextMenu>
						<toolkit:MenuItem Header="Supprimer" Click="Delete_Click" />
					</toolkit:ContextMenu>
				</toolkit:ContextMenuService.ContextMenu>
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition />
						<ColumnDefinition Width="Auto" />
					</Grid.ColumnDefinitions>
					<TextBlock Text="{Binding Name}" FontSize="{StaticResource PhoneFontSizeLarge}" />
					<TextBlock Grid.Column="2" Text="{Binding SongCount}" Foreground="{StaticResource PhoneAccentBrush}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" VerticalAlignment="Center"/>
				</Grid>
			</Border>
		</DataTemplate>
	</phone:PhoneApplicationPage.Resources>
	<phone:PhoneApplicationPage.ApplicationBar>
		<shell:ApplicationBar>
			<shell:ApplicationBarIconButton IconUri="/icons/appbar.add.rest.png" IsEnabled="True" Text="Nouvelle" Click="New_Click"/>
		</shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>

	<phone:PhoneApplicationPage.FontFamily>
		<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
	</phone:PhoneApplicationPage.FontFamily>
	<phone:PhoneApplicationPage.FontSize>
		<StaticResource ResourceKey="PhoneFontSizeNormal"/>
	</phone:PhoneApplicationPage.FontSize>
	<phone:PhoneApplicationPage.Foreground>
		<StaticResource ResourceKey="PhoneForegroundBrush"/>
	</phone:PhoneApplicationPage.Foreground>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="{StaticResource ApplicationNameUC}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="listes" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

    	<ListBox Grid.Row="1" Margin="12,0,12,0" d:DataContext="{Binding Source={StaticResource PlaylistsDataSource}}" DataContext="{Binding ElementName=phoneApplicationPage}" ItemsSource="{Binding Playlists}" ItemTemplate="{StaticResource PlaylistsItemTemplate}" ItemContainerStyle="{StaticResource ListBoxItemWithNoSelectionStyle}" />
    </Grid>

</phone:PhoneApplicationPage>
